package com.cn.pojo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.math.BigDecimal;
import java.util.Date;
import java.util.regex.Pattern;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
    * 订单表
    */
@ApiModel(value="com-cn-pojo-Orders")
@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName(value = "orders")
public class Orders {
    /**
     * 主键
     */
    @TableId(value = "id", type = IdType.INPUT)
    @ApiModelProperty(value="主键")
    private Long id;

    /**
     * 订单号
     */
    @TableField(value = "number")
    @ApiModelProperty(value="订单号")
    private String number;

    /**
     * 订单状态 1待付款，2待派送，3已派送，4已完成，5已取消
     */
    @TableField(value = "status")
    @ApiModelProperty(value="订单状态 1待付款，2待派送，3已派送，4已完成，5已取消")
    private Integer status;

    /**
     * 下单用户
     */
    @TableField(value = "user_id")
    @ApiModelProperty(value="下单用户")
    private Long userId;

    /**
     * 地址id
     */
    @TableField(value = "address_book_id")
    @ApiModelProperty(value="地址id")
    private Long addressBookId;

    /**
     * 下单时间
     */
    @TableField(value = "order_time")
    @ApiModelProperty(value="下单时间")
    private Date orderTime;

    /**
     * 结账时间
     */
    @TableField(value = "checkout_time")
    @ApiModelProperty(value="结账时间")
    private Date checkoutTime;

    /**
     * 支付方式 1微信,2支付宝
     */
    @TableField(value = "pay_method")
    @ApiModelProperty(value="支付方式 1微信,2支付宝")
    private Integer payMethod;

    /**
     * 实收金额
     */
    @TableField(value = "amount")
    @ApiModelProperty(value="实收金额")
    private BigDecimal amount;

    /**
     * 备注
     */
    @TableField(value = "remark")
    @ApiModelProperty(value="备注")
    private String remark;

    @TableField(value = "phone")
    @ApiModelProperty(value="")
    private String phone;

    @TableField(value = "address")
    @ApiModelProperty(value="")
    private String address;

    @TableField(value = "user_name")
    @ApiModelProperty(value="")
    private String userName;

    @TableField(value = "consignee")
    @ApiModelProperty(value="")
    private String consignee;

    @TableField(value = "express")
    @ApiModelProperty(value="")
    private Integer express;

    @TableField(value = "logistics_no")
    @ApiModelProperty(value="")
    private String logisticsNo;



    /**
     * 菜品名称
     */
    @TableField(exist = false)
    @ApiModelProperty(value="菜品名称")
    private String name;

    /**
     * 菜品图片
     */
    @TableField(exist = false)
    @ApiModelProperty(value="菜品图片")
    private String image;

    /**
     * 菜品价格
     */
    @TableField(exist = false)
    @ApiModelProperty(value="菜品价格")
    private String price;

    /**
     * 商品码
     */
    @TableField(exist = false)
    @ApiModelProperty(value="商品码")
    private String code;

    /**
     * 口味
     */
    @TableField(exist = false)
    @ApiModelProperty(value="口味")
    private String flavor;

    @TableField(exist = false)
    @ApiModelProperty(value="份数")
    private String copies;

    @TableField(exist = false)
    @ApiModelProperty(value="省")
    private String addressProvince;

    @TableField(exist = false)
    @ApiModelProperty(value="市")
    private String addressCity;
    
    @TableField(exist = false)
    @ApiModelProperty(value="区")
    private String addressTown;

    @TableField(exist = false)
    @ApiModelProperty(value="详细地址")
    private String detailAddress;


    public String getAddress() {
//        String regex  = "(?<addressProvince>[^省]+省|.+自治区|[^澳门]+澳门|[^香港]+香港|[^市]+市)?(?<addressCity>[^自治州]+自治州|[^特别行政区]+特别行政区|[^市]+市|.*?地区|.*?行政单位|.+盟|市辖区|[^县]+县)(?<addressTown>[^县]+县|[^市]+市|[^镇]+镇|[^区]+区|[^乡]+乡|.+场|.+旗|.+海域|.+岛)?(?<detailAddress>.*)";
//        Pattern pattern = Pattern.compile(regex);
//        String[] result = pattern.split(address);
//        for(String s : result)
//        {
//            System.out.println(s);
//
//        }
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public static final String COL_ID = "id";

    public static final String COL_NUMBER = "number";

    public static final String COL_STATUS = "status";

    public static final String COL_USER_ID = "user_id";

    public static final String COL_ADDRESS_BOOK_ID = "address_book_id";

    public static final String COL_ORDER_TIME = "order_time";

    public static final String COL_CHECKOUT_TIME = "checkout_time";

    public static final String COL_PAY_METHOD = "pay_method";

    public static final String COL_AMOUNT = "amount";

    public static final String COL_REMARK = "remark";

    public static final String COL_PHONE = "phone";

    public static final String COL_ADDRESS = "address";

    public static final String COL_USER_NAME = "user_name";

    public static final String COL_CONSIGNEE = "consignee";

    public static final String COL_EXPRESS = "express";
}